//
//  YZMRedPacketCell.m
//  YZMicroStock
//
//  Created by apple on 17/5/2.
//  Copyright © 2017年 cqjr. All rights reserved.
//

#import "YZMRedPacketCell.h"
#import <NSDate+DateTools.h>

@interface YZMRedPacketCell ()
@property (nonatomic, strong) UILabel *titleLB;
@property (nonatomic, strong) UILabel *timeLB;
@property (nonatomic, strong) UILabel *priceLB;

@end

@implementation YZMRedPacketCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self createObjects];
        self.leftMargin = 10.0;
        self.rightMargin = 10.0;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    return self;
}

- (void)createObjects {
    
    WS(ws)
    self.titleLB = [YZMAppStyle labelWithMediumWhite];
    [self addSubview:self.titleLB];
    [self.titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.equalTo(ws).offset(15);
    }];
    
    self.timeLB = [YZMAppStyle labelWithSmallLightGray];
    [self addSubview:self.timeLB];
    [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(ws.titleLB.mas_bottom).with.offset(7);
        make.left.equalTo(ws.titleLB);
    }];
    
    UILabel *yuanLB = [YZMAppStyle labelWithMediumWhite];
    yuanLB.textColor = [YZMAppStyle colorForRiseText];
    [self addSubview:yuanLB];
//    yuanLB.text = @"元";
    [yuanLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(ws.titleLB);
        make.right.equalTo(ws).offset(-15);
    }];
    
    self.priceLB = [YZMAppStyle labelWithMediumWhite];
    self.priceLB.textColor = [YZMAppStyle colorForRiseText];
    [self addSubview:self.priceLB];
    [self.priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(yuanLB);
        make.right.equalTo(yuanLB.mas_left).offset(-1);
    }];
}

-(void)setModel:(YZMRedPacketListModel *)model{
    
    self.titleLB.text = [model tradeDescription];
    self.timeLB.text = [model.time formattedDateWithFormat:@"yyyy/MM/dd HH:mm:ss"];
    
    self.priceLB.text = [model showPrice];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
